package grm;

import grm.database.IDatabase;
import grm.database.TextDatabase;
import grm.role.Admin;
import grm.role.Customer;
import grm.role.Merchant;
import grm.role.RoleBase;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        RoleBase role = login();
        role.login();
        IDatabase db = TextDatabase.getInstance();
        System.out.println("It today 11.11? [0/1]");
        Scanner in = new Scanner(System.in);
        if (in.nextInt() != 1) {
            db.initDatabase("F:\\workspace\\javaespresso\\onlineStore\\src\\main\\resources\\normal.config");
        } else {
            db.initDatabase("F:\\workspace\\javaespresso\\onlineStore\\src\\main\\resources\\double11.config");
        }
        role.work();
    }

    public static RoleBase login() {
        System.out.print("""
                Who are you?
                1. Custumer
                2. Merchant
                3. Admin
                """);
        Scanner in = new Scanner(System.in);
        int choice = in.nextInt();
        RoleBase role = null;
        switch(choice) {
            case 1:
                role = new Customer();
                break;
            case 2:
                role = new Merchant();
                break;
            case 3:
                role = new Admin();
                break;
        }
        return role;
    }
}
